package org.lai.mapper;

import org.apache.ibatis.annotations.*;
import org.lai.pojo.Clazz;
import org.lai.pojo.ClazzQueryParam;

import java.util.List;

@Mapper
public interface ClazzsMapper {
    /**
     * 分页查询
     * @param clazzQueryParam 前端传递的数据
     * @return
     */
    List<Clazz> list(ClazzQueryParam clazzQueryParam);

    /**
     * 添加班级全部信息
     */
    @Insert("insert into clazz(name, room, begin_date, end_date, master_id, subject, create_time, update_time) values(" +
            "#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    /**
     * 回显
     * @param id
     * @return
     */
    @Select("select c.*,e.name masterName from clazz c left join emp e on c.master_id = e.id where c.id = #{id}")
    Clazz getInfo(Integer id);

    /**
     * 修改班级信息
     * @param clazz
     */

    void update(Clazz clazz);

    /**
     * 删除班级信息
     * @param id
     */
    @Delete("delete from clazz where id = #{id}")
    void deleteById(Integer id);

    /**
     * 查询班级学生人数
     *
     * @param id
     * @return
     */
    @Select("select count(*) from student where clazz_id = #{id}")
    Integer getClazzsStudentCount(Integer id);

    /**
     * 查询全部班级
     * @return
     */
    @Select("select * from clazz")
    List<Clazz> getList();
}
